//
//  ViewController.m
//  UI13_xib创建自定义cell
//
//  Created by Scott on 16/3/25.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "ViewController.h"
#import "TableViewOfFilm.h"
#import "CellOfFilm.h"

@interface ViewController () <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) TableViewOfFilm *tableView;

@end


@implementation ViewController

- (void)dealloc {
    
    [_tableView release];
    [super dealloc];
    
}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.navigationItem.title = @"xib 自定义cell";
    
    [self createTableView];

}

#pragma mark - tableView 
- (void)createTableView {
    
    self.tableView = [[TableViewOfFilm alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    [_tableView release];
    
    
    // 注册xib格式的cell
    
    UINib *nib = [UINib nibWithNibName:@"CellOfFilm" bundle:[NSBundle mainBundle]];
    
    [self.tableView registerNib:nib forCellReuseIdentifier:@"pool"];
    

}

#pragma mark - tableView DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    CellOfFilm *cell = [tableView dequeueReusableCellWithIdentifier:@"pool"];
    
    
    
    return cell;
}


#pragma mark - tableView delegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    
    return 200;
}





#pragma mark -
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
